<template>
	<view>
		<Navbar :backUrl="'mine'"></Navbar>
		<view class="u-m-30">
			<view class="u-flex">
				<u-image width="120" height="120" shape="circle"
					:src="presidentInfo.user.head_img"
					mode="" />
				<view class="u-m-l-30 u-flex-1 u-flex u-row-between">
					<view class="u-flex-1">
						<view class="u-flex u-flex-1 u-m-t-10">
							<view class="u-font-bold u-font-34 u-m-r-10">{{ presidentInfo.user.name }}</view>
							<view class="u-m-r-10" v-if="presidentInfo.user.is_authentication == 2">
								<u-icon size="32" color="#FB6316" name="renzheng" custom-prefix="custom-icon" />
							</view>
							<view class="u-m-r-10" v-if="presidentInfo.user.is_company_user == 1">
								<u-icon size="32" name="qiye1" color="#F8494D" custom-prefix="custom-icon" />
							</view>
							<view class="u-tag-box" :class="presidentInfo.user.president_class"
								v-if="presidentInfo.user.president_class">{{ presidentInfo.user.president_name }}</view>
						</view>
						<view>
							<view class="u-m-t-10 u-font-bold">
								<span>当前能量分：</span>
								<span>{{presidentInfo.jiu.number}}</span>
							</view>
							<view style="width: 400rpx;margin-top: -10rpx;">
								<u-line-progress :percent="presidentInfo.info.process" :height="8"
									active-color="#2C76ED" inactive-color="#C0C6D1"
									:show-percent="false"></u-line-progress>
							</view>
							<view class="u-font-24 u-color-gray">
								<!-- <span class="u-font-bold">{{presidentInfo.info.count}}</span>
								<span>/{{presidentInfo.info.total}}</span> -->
								<span class="u-m-l-10">{{ presidentInfo.user.president_text }}</span>
							</view>
						</view>
					</view>
				</view>
			</view>
			<!-- 邀请奖励 -->
			<!-- <view class="u-m-t-30 u-radius-20 record_box">
				<view class="record_title" @click="goPaymentForm">
					<view>完善收款账户信息</view>
					<view class="u-m-r-10">{{ presidentInfo.info.accountLabel }}</view>
				</view>
				<view class="record_content" @click="goRecordList">
					<view class="u-p-r-60 u-flex-1 record_line">
						<view class="u-font-26">我的收入</view>
						<view class="record_price">{{ presidentInfo.info.invite_money || 0}}</view>
					</view>
					<view class="u-m-l-40 u-flex-1">
						<view class="u-font-26">已发放</view>
						<view class="record_price">{{ presidentInfo.info.grant_invite_money || 0}}</view>
					</view>
				</view>
			</view> -->
			<!-- 场地管理 -->
			<!-- <view class="u-back-white u-m-t-30 u-p-t-30 u-p-b-30 u-p-l-20 u-p-r-20 u-radius-20 u-flex u-row-between"
				@click="goAddressList">
				<view class="u-font-30 u-font-bold u-flex">
					<view>场地管理</view>
					<view class="u-m-l-15 u-tag-box u-back-red" v-if="presidentInfo.info.address_count > 0">
						{{ presidentInfo.info.address_count}}个</view>
				</view>
				<view class="u-color-gray u-font-26">管理场地 ></view>
			</view> -->
			<!-- 青创私董权益 -->
			<view class="u-m-t-30 u-p-t-20 u-p-b-20 u-p-l-30 u-p-r-30 u-radius-20 u-back-light"
				@click="goViewAgreement">
				<view class="u-flex u-row-between">
					<view class="u-flex-1 u-flex">
						<u-image src="https://lrcj.oss-cn-shenzhen.aliyuncs.com/images/common/20241028398180471220.png"
							width="80" height="90"></u-image>
						<view class="u-m-l-20">
							<view class="u-font-bold u-font-30">青创私董权益</view>
							<!-- <view class="u-m-t-10">获得金额奖励</view> -->
						</view>
					</view>
					<view class="u-flex u-back-puce u-color-white view_box u-p-t-10 u-p-b-10">
						<view>立即查看 ></view>
					</view>
				</view>
			</view>
			<!-- 邀请注册 -->
			<view class="u-m-t-30 u-p-t-20 u-p-b-20 u-p-l-30 u-p-r-30 u-radius-20 u-back-light"
				@click="goInviteList">
				<view class="u-flex u-row-between">
					<view class="u-flex-1 u-flex">
						<u-image src="https://lrcj.oss-cn-shenzhen.aliyuncs.com/images/common/20241028398180471220.png"
							width="80" height="90"></u-image>
						<view class="u-m-l-20">
							<view class="u-font-bold u-font-30">邀请新青创私董</view>
							<!-- <view class="u-m-t-10">获得金额奖励</view> -->
						</view>
					</view>
					<view class="u-flex u-back-puce u-color-white view_box u-p-t-10 u-p-b-10">
						<view>立即邀请 ></view>
					</view>
				</view>
			</view>
			<!-- 青创私董学院 -->
			<view class="u-back-white u-m-t-30 u-p-t-30 u-p-b-30 u-p-l-20 u-p-r-20 u-radius-20"
				v-if="collegeList && collegeList[0]">
				<view class="u-flex u-row-between u-p-b-30 u-line-bottom">
					<view class="u-font-30 u-font-bold">青创私董学院</view>
					<view class="u-color-gray u-font-26" @click="goCollegeList">查看更多 ></view>
				</view>
				<view class="u-m-t-20 u-flex u-row-between u-col-top">
					<view style="width: 47%;" v-for="item in collegeList" :key="item.id"
						@click="goCollegeDetail(item.id)">
						<u-image width="100%" height="240rpx" border-radius="10" :src="item.img_wap" mode="aspectFill"></u-image>
						<view class="u-font-bold u-m-t-10">{{item.title}}</view>
					</view>
				</view>
			</view>
			<!-- 运营活动 -->
			<view class="u-back-white u-m-t-30 u-p-t-30 u-p-b-30 u-p-l-20 u-p-r-20 u-radius-20"
				v-if="costsList && costsList[0]">
				<view class="u-flex u-row-between u-p-b-30 u-line-bottom">
					<view class="u-font-30 u-font-bold">运营活动</view>
					<view class="u-color-gray u-font-26" @click="goCostsList">查看更多 ></view>
				</view>
				<view class="u-flex u-col-top u-m-t-20" v-for="item in costsList" :key="item.id" @click="goCostsDetail(item.id)">
					<view class="u-m-r-20" v-if="item.tpic">
						<u-image width="200rpx" height="140rpx" border-radius="10" :src="item.tpic"></u-image>
					</view>
					<view class="u-flex-1">
						<view class="u-font-30 u-font-bold u-text-line-15">{{item.title}}</view>
						<view class="u-flex u-color-gray u-m-t-10">
							<view>有效期</view>
							<view class="u-font-26 u-m-l-10">{{item.create_time}}</view>
						</view>
					</view>
				</view>
			</view>
			<!-- 商品优选 -->
			<!-- <view class="u-back-white u-m-t-30 u-p-t-30 u-p-b-30 u-p-l-20 u-p-r-20 u-radius-20">
				<view class="u-flex u-row-between u-p-b-30 u-line-bottom">
					<view class="u-font-30 u-font-bold">亲萃优选</view>
					<view class="u-color-gray u-font-26" @click="goPointShop">查看更多 ></view>
				</view>
				<view class="u-m-t-20 u-flex u-row-between">
					<u-image width="150rpx" height="150rpx"
						src="https://cdn.uviewui.com/uview/example/fade.jpg"></u-image>
					<view class="u-flex-1 u-m-l-20" style="150rpx">
						<view class="u-m-t-5 u-font-34 u-font-bold">XXX商品</view>
						<view class="u-m-t-10 u-flex u-row-between">
							<view class="u-flex">
								<view>
									<view class="u-color-gray u-font-24">活动价</view>
									<view class="u-color-red u-m-t-5">
										<span>¥</span>
										<span class="product_price">68</span>
									</view>
								</view>
								<view class="u-m-l-50">
									<view class="u-color-gray u-font-24">佣金赚</view>
									<view class="u-color-red u-m-t-5">
										<span>¥</span>
										<span class="product_price">68</span>
									</view>
								</view>
							</view>
							<view class="u-text-center">
								<view class="u-color-blue u-font-24">98+人付款</view>
								<view class="product_tag u-back-red u-m-t-10">立即分享</view>
							</view>
						</view>
					</view>
				</view>
			</view> -->
		</view>
	</view>
</template>

<script>
	import Navbar from '@/components/Navbar.vue'
	import { presidentInfo } from '@/network/api.js'
	import { getActivityList } from '@/network/demand.js'
	import { teaCostsNesList } from '@/network/tea.js'
	import {
		PresidentLevel,
    TeaStatus,
		presidentClass,
		PartnerLevel
	} from '@/utils/index.js'
	export default {
		components: {
			Navbar
		},
		data() {
			return {
				user_id: uni.getStorageSync("user_id"),
				presidentInfo: {},
				collegeList: [], // 青创私董学院列表
				costsList: [], // 运营活动列表
			}
		},
		onLoad() {
			this.getPresidentInfo()
			this.getPresidentCollege()
			this.getCostsList()
		},
		mounted(){
			let _this = this
			uni.$on('update',function(){
				_this.getPresidentInfo()
			})
		},
		onUnload() {
			uni.$off('update')
		},
		methods: {
			getPresidentInfo() {
				presidentInfo({
					user_id: this.user_id
				}).then(res => {
					let diff = parseInt(res.data.jiu.diff)
					let number = parseInt(res.data.jiu.number)
					res.data.info.total = number
					res.data.info.process = parseInt(number / (number + diff) * 100)
					res.data.user.president_status = parseInt(res.data.user.president_status)
					res.data.user.president_name = this.getPresidentName('', res.data.user.president_status)
					res.data.user.president_class = presidentClass(res.data.user.president_status)
					switch (res.data.user.president_status) {
						case 5:
						case 6:
						case 7:
						case 8:
							res.data.user.president_text =
								`差${res.data.jiu.diff}能量分即可升级${this.getPresidentName('', res.data.user.president_status + 1)}`

							break;
						case 9:
							res.data.user.president_text = ``
							break;
					}
					switch(res.data.info.is_account){
						case 0:
						    res.data.info.accountLabel = '去完善 >'
						    res.data.info.accountValue = 1
							break;
						case 1:
						    if(res.data.account.status == 1){
								res.data.info.accountLabel = '审核中 >'
								res.data.info.accountValue = 2
							}
						    if(res.data.account.status == 2){
								res.data.info.accountLabel = '审核完成，去提现 >'
								res.data.info.accountValue = 3
							}
							break;
					}
					this.presidentInfo = res.data
				})
			},
			getPresidentCollege() {
				const params = {
					page: 1,
					limit: 2,
					is_president: 5
				}
				getActivityList(params).then(res => {
					this.collegeList = res.data.list
				})
			},
			async getCostsList(){
				const params = {
					type_id: 1,
					page: 1,
					limit: 2
				}
				const res = await teaCostsNesList(params)
				this.costsList = res.data.list
			},
			getPresidentName(status1, status2) {
        return TeaStatus(status1, status2)  
				// return PresidentLevel(status)
			},
			goAddressList() {
				uni.navigateTo({
					url: "/pages/addressList/addressList"
				})
			},
			goCollegeList() {
				uni.navigateTo({
					url: "/operate/collegeList/collegeList"
				})
			},
			goPointShop(){
				uni.navigateTo({
					url: "/teaBureau/teaPointShop/teaPointShop"
				})
			},
			goCollegeDetail(id) {
				uni.navigateTo({
					url: "/pages/activityDetail/activityDetail?id=" + id + '&isBack=true'
				})
			},
			goInviteList() {
				uni.navigateTo({
					url: "/teaBureau/teaInviteList/teaInviteList?type=1"
				})
			},
			goRecordList(){
				uni.navigateTo({
					url: "/operate/recordList/recordList"
				})
			},
			goPaymentForm(){
				uni.navigateTo({
					url: "/operate/paymentForm/paymentForm?type=" + this.presidentInfo.info.accountValue
				})
			},
			goViewAgreement(){
				uni.navigateTo({
					url: '/operate/agreement/agreement?type=29'
				})
			},
			goCostsList(){
				uni.navigateTo({
					url: "/teaBureau/teaCostsList/teaCostsList?type=1"
				})
			},
			goCostsDetail(id){
				uni.navigateTo({
					url: "/teaBureau/teaCostsDetail/teaCostsDetail?id=" + id
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.income_box {
		background: #3E4350;
		padding: 20rpx 30rpx;
		border-radius: 20rpx;
	}

	.income_btn {
		background: #E6C77D;
		color: #604504;
		padding: 10rpx 18rpx;
		border-radius: 50rpx;
	}

	.product_price {
		font-size: 40rpx;
		font-weight: bold;
		margin-left: 5rpx;
	}

	.product_tag {
		height: 56rpx;
		line-height: 56rpx;
		color: #fff;
		padding: 0 30rpx;
		font-size: 26rpx;
		border-radius: 50rpx;
	}
	
	.record_box{
		
		.record_title{
			display: flex;
			justify-content: space-between;
			background: #B3723E;
			color: #fff;
			padding: 15rpx 20rpx 30rpx 20rpx;
			border-top-right-radius: 20rpx;
			border-top-left-radius: 20rpx;
			font-size: 26rpx;
		}
		
		.record_content{
			margin-top: -10rpx;
			padding: 20rpx 30rpx;
			display: flex;
			border-radius: 20rpx;
			border: 1rpx solid #fff;
			background: linear-gradient(to bottom, #FBECE2, #FFFEFD);
		}
		
		.record_price{
			font-size: 48rpx;
			font-weight: bold;
			margin-top: 5rpx;
		}
		
		.record_line{
			border: 1rpx solid #EFE5DE;
			border-width: 0 4rpx 0 0;
		}
	}
	
</style>